﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace TestEDAS
{
    class TestRunner
    {
        private Dictionary<string,Action> testList;
        Stopwatch sw;

        public TestRunner()
        {
            sw = new Stopwatch();
            testList = new Dictionary<string, Action>();
        }

        public void AddTest(string Name,Action Test)
        {
            testList.Add(Name, Test);
        }
        public void RunTest()
        {
            long ms = 0;
            foreach (string Name in testList.Keys)
            {
                try
                {
                    sw.Start();
                    testList[Name]();
                    sw.Stop();
                    ms = sw.ElapsedMilliseconds;
                    sw.Reset();
                    Console.WriteLine(Name + " test ok use time:" + ms + " ms");
                }
                catch(Exception ex)
                {
                    Console.WriteLine(Name + " test faild with exception:" + ex.Message);
                }
            }
        }

    }
}
